package gbench.appdemo.mall.junit;

import org.junit.jupiter.api.Test;

import gbench.appdemo.mall.data.ConfigApp.*;

import static gbench.common.tree.LittleTree.IRecord.*;
import static gbench.common.tree.LittleTree.*;
import gbench.common.tree.LittleTree;

/**
 * 
 * @author gbench
 *
 */
public class JunitMallConfig {

    @Test
    public void foo() {
        // 生成用户数据
        final var users = TUPLES("张三", "李四", "王五")
            .map(e -> REC("id", e._1(), "name", e._2()))
            .map(rec -> rec.mutate(Tenant.class)).toArray(Tenant[]::new);
        
        // 生成用户数据
        final var apps = TUPLES("订单模块", "商品模块", "用户模块")
            .map(e -> REC("id", e._1(), "name", e._2(),
                "configItems",L("jdbc.url","jdbc.driver","jdbc.user","jdbc.password")))
            .map(rec -> rec.mutate(TenantApp.class)).toArray(TenantApp[]::new);
        
        String[] names = "tenant,tenantApp".split(",");// 键名序列
        LittleTree.cph2(users,apps)
        .map(rec->rec.keys(names).mutate(TenantAppConfig.class))
        .forEach(e->{
            System.out.println(e);
        });
        
    }

}
